
import request from '@/utils/request'
import qs from "qs"
export default {

    //分页获取品牌列表 (get请求只能用params:{}来传递参数)
    listAll() {
        return request({
            url: '/api-goods/proBrand/brands/available/all',
            method: 'get'
        })
    },
    // 获取可用的品牌信息（只包含ID和名称）
    listBaseInfo() {
        return request({
            url: '/api-goods/proBrand/brands/baseAvailable',
            method: 'get'
        })
    },
    //分页获取品牌列表 (get请求只能用params:{}来传递参数)
    pageList(pageNum, pageSize, sort) {
        return request({
            url: '/api-goods/proBrand/brands',
            method: 'get',
            params: { pageNum, pageSize, sort }
        })
    },
    //根据品牌名称获取品牌列表
    // pageMatch(pageNum, pageSize, sort, matchName) {
    // 简化传递参数
    pageMatch(data) {
        return request({
            url: '/api-goods/proBrand/brands/match',
            method: 'get',
            // params: { pageNum, pageSize, sort, matchName }
            params: data
        })
    },
    //当前列表中生成首字母
    generateInitial(pageNum, pageSize) {
        var data = qs.stringify({ pageNum, pageSize })
        // console.log(data)
        return request({
            url: '/api-goods/proBrand/brands/generateInitial',
            method: 'put',
            data
        })
    },
    //根据id删除品牌数据
    deleteById(id) {
        return request({
            url: `/api-goods/proBrand/brand/${id}`,
            method: 'delete'
        })
    },
    //根据id批量删除品牌数据
    batchOperation(ids, type) {
        var data = qs.stringify({ ids, type })
        return request({
            url: `/api-goods/proBrand/brands`,
            method: 'post',
            data
        })
    },
    //根据id修改数据
    updateById(brand) {
        var data = qs.stringify(brand)
        return request({
            url: '/api-goods/proBrand/brand',
            method: 'put',
            data
        })
    },
    // 添加品牌
    addBrand(brand) {
        var data = qs.stringify(brand)
        return request({
            url: '/api-goods/proBrand/brand',
            method: 'post',
            data
        })
    }

}